package com.lanou.dllo.findfood.adpter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lanou.dllo.findfood.R;
import com.lanou.dllo.findfood.entity.Dardry;

import java.util.ArrayList;

/**
 * Created by dllo on 15/10/26.
 */
public class MyListAdpter extends BaseAdapter {
    LayoutInflater inflater;
    ArrayList<Dardry> array;
    public MyListAdpter(LayoutInflater inf,ArrayList<Dardry> arry){
        this.inflater=inf;
        this.array=arry;
    }
    @Override
    public int getCount() {
        return array.size();
    }

    @Override
    public Object getItem(int position) {
        return array.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder vh;
        if(convertView==null){
            vh=new ViewHolder();
            convertView=inflater.inflate(R.layout.list_adpter, null);//加载行布局
            vh.title=(TextView) convertView.findViewById(R.id.TitleView);
            vh.time=(TextView) convertView.findViewById(R.id.NowTime);
            convertView.setTag(vh);//将得到的内容添加到视图中
        }
        vh=(ViewHolder) convertView.getTag();
        vh.title.setText(array.get(position).getTitle());
        vh.time.setText(array.get(position).getTimes());
        return convertView;


    }
    class ViewHolder{
        TextView title,time;
    }
}
